﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter4.Section4
{
    public class Example01
    {
        public Example01()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double[], double[]> f
                = new V.Function.ToLastType<double[], double[]>(ff);
            double[] x = {1.0,2.0,3.0};
            V.Divergence deldotf = new V.Divergence(f,x);
            deldotf.Compute();
            result += deldotf.Result.ToString() + "\r\n";
            x[0] = 2.0;
            x[1] = 4.0;
            x[2] = 3.0;
            deldotf.Compute();
            result += deldotf.Result.ToString() + "\r\n";
        }
        private double[] ff(double[] x)
        {
            double[] r = new double[3];
            r[0] = x[0] * x[0] * x[1];
            r[1] = x[2];
            r[2] = x[0] * x[1] * x[2];
            return r;
        }
    }
}
// 5.99999999999979
// 24.0000000000064
   
